package com.framework.controller.newcontroller;


import com.framework.exception.util.RespResult;
import com.framework.service.TransactionInfoService;
import com.framework.service.index.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wq
 */
@RestController
@Api(value="首页模块",tags={"首页模块"})
@RequestMapping("new/index")
public class IndexController {


    @Autowired
    private IndexService indexService;

    @Autowired
    private TransactionInfoService transactionInfoService;

    /**
     * 获取首页信息
     * @param token
     * @return
     */
    @GetMapping("user/getIndexInfo")
    @ApiOperation("获取首页相关信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="用户登录的token",dataType="string", paramType = "query",required = true)
    })
    public  RespResult getIndexInfo(String token){
        Map<String,Object> map=indexService.getIndexInfo(token);
        return RespResult.ok(map);
    }

    /**
     * 功能描述: 首页的交易数据信息
     * @param token 登录所需的token
     */
    @GetMapping("user/getIndexTransaction")
    @ApiOperation("获取代理商首页数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name="type",value="类型 1：昨日  2：当月",dataType="int", paramType = "query" ,required = true)
    })
    public RespResult getAgentInfoByToken(String token,Integer type) {
        Map<String,Object> map = transactionInfoService.getIndexTransaction(token,type);
        return RespResult.ok().put("data",map);
    }
}
